json.result   true
json.message  "获取商品成功"
json.data         do
  json.id                     @spu.id
  json.name                   @spu.name
  json.sales_volume           @spu.sales_volume
  json.avatar                 @spu.avatar.url("50percent")
  json.description            @spu.description
  json.published              @spu.published
  json.promotion              @spu.promotion
  json.seven_day_back         @spu.seven_day_back
  json.genuine_product        @spu.genuine_product
  json.low_promotion_price    "#{@current_user.blank? ? @spu.protect_low_promotion_price : @current_user.computed_price(@spu.low_promotion_price)}"
  json.high_promotion_price   "#{@current_user.blank? ? @spu.protect_high_promotion_price : @current_user.computed_price(@spu.high_promotion_price)}"
  json.low_sale_price         "#{@current_user.blank? ? @spu.protect_low_sale_price : @current_user.computed_price(@spu.low_sale_price)}"
  json.high_sale_price        "#{@current_user.blank? ? @spu.protect_high_sale_price : @current_user.computed_price(@spu.high_sale_price)}"
  json.low_cost_price         "#{@current_user.blank? ? @spu.protect_low_cost_price : @current_user.computed_price(@spu.low_cost_price)}"
  json.high_cost_price        "#{@current_user.blank? ? @spu.protect_high_cost_price : @current_user.computed_price(@spu.high_cost_price)}"
  json.can_use_coupon         @spu.can_use_coupon
  json.favorited              @current_user.presence ? @spu.is_favorited?(@current_user.id) : false
  json.stock                  @spu.stock
  json.express_fee            "#{@spu.default_express_fee}"
  json.direct_sale            @spu.shop.direct_sale
  json.shop                   do
    json.id                   @spu.shop.id
    json.name                 @spu.shop.name
    json.avatar               @spu.shop.avatar.url("50percent")
    json.province             @spu.shop.province.blank? ? "" : @spu.shop.province.name
    json.city                 @spu.shop.city.blank? ? "" : @spu.shop.city.name
    json.district             @spu.shop.district.blank? ? "" : @spu.shop.district.name
    json.phone                @spu.shop.phone
    json.longitude            @spu.shop.longitude
    json.latitude             @spu.shop.latitude
    json.area                   Setting.fetch("city_or_district") == 'city' ? (@spu.shop.city.blank? ? '' : @spu.shop.city.name) : (@spu.shop.district.blank? ? '' : @spu.shop.district.name)
  end
  json.shop_category          do
    json.id                   @spu.shop_category.id
    json.name                 @spu.shop_category.name
  end
  if @spu.brand.presence
    json.brand       do
      json.id                 @spu.brand.id
      json.name               @spu.brand.name
      json.avatar             @spu.brand.avatar.url
      json.big_avatar         @spu.brand.big_avatar.url
    end
  end
  json.pictures               @spu.spu_images do |spu_image|
    json.id                   spu_image.id
    json.url                  spu_image.image.url
  end
  json.parameters             @spu.spu_parameters do |spu_parameter|
    json.key                  spu_parameter.param_key
    json.value                spu_parameter.param_value
  end
  json.details                @spu.spu_details do |spu_detail|
    json.url                  spu_detail.image.url
  end
  json.service_items          @spu.service_items do |service_item|
    json.avatar               service_item.avatar.url
    json.name                 service_item.name
    json.description          service_item.description
  end
  json.skus             @spu.skus do |sku|
    json.id               sku.id
    json.name             sku.name
    json.cost_price       "#{@current_user.blank? ? '*****' : sku.cost_price}"
    json.sale_price       "#{@current_user.blank? ? '*****' : sku.sale_price}"
    json.promotion_price  "#{@current_user.blank? ? '*****' : sku.promotion_price}"
    json.on_hand_count    sku.on_hand_count
    json.option_values    sku.option_values do |option_value|
      json.id                option_value.id
      json.presentation      option_value.presentation
      json.name              option_value.name
    end
    json.avatar           sku.avatar.url("50percent")
  end
  json.option_type      @spu.shop_category.parent.option_types do |option_type|
    json.id               option_type.id
    json.name             option_type.name
    json.option_value     option_type.option_values.each do |option_value|
      if @spu.has_option_values(option_type).include?(option_value.id)
        json.id                option_value.id
        json.presentation      option_value.presentation
        json.name              option_value.name
      end
    end
  end
  json.coupons              @spu.coupons.where(state: :usable).where("end_at >= ?", Time.now.to_datetime) do |coupon|
    json.id                     coupon.id
    json.name                   coupon.name
    json.remark                 coupon.remark
    json.start_at               formattime(coupon.start_at, unit: "hour")
    json.end_at                 formattime(coupon.end_at, unit: "hour")
    json.money                  coupon.money
    json.full_money             coupon.full_money
    if @user.presence
      json.had                  @user.coupon_had(coupon)
    end
  end
  json.comments             @spu.comments.limit(5) do |comment|
    json.id                     comment.id
    json.content                comment.content
    json.review                 comment.review
    json.hide_user              comment.hide_user
    json.score                  comment.score
    json.created_at             formattime(comment.created_at, unit: "day")
    json.created_time_at        formattime(comment.created_at, unit: "noDayOnlyHour")
    json.order_item             do
      json.id                     comment.order_item_id
    end
    json.user                   do
      json.id                     comment.user.id
      json.nickname               comment.user.nickname
      json.avatar                 comment.user.avatar.url
    end
  end
  json.service_url              @service_url
  json.share_title              @spu.name
  json.share_content            @spu.description
  json.share_avatar             @spu.avatar.url
  json.share_url                "#{Setting.fetch("android_download_url")}"
end